package org.ishequ.service;

import java.util.HashMap;
import java.util.Map;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class SettingService {

	private Context context;
	
	public SettingService(Context context) {
		this.context = context;
	}

	public void save(String name, int age) {
		SharedPreferences preferences = context.getSharedPreferences("user", context.MODE_PRIVATE);
		Editor editor = preferences.edit();
		editor.putString("name", name);
		editor.putInt("age", age);
		editor.commit();
	}
	
	public Map<String,String> getSettings(){
		Map<String,String> settings = new HashMap<String,String>();
		SharedPreferences preferences = context.getSharedPreferences("user", context.MODE_PRIVATE);
		settings.put("name", preferences.getString("name", ""));
		settings.put("age", String.valueOf(preferences.getInt("age",0)));
		return settings;
	}

}
